#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import sys
import os


def the_cp(sourcefile, destfile):
    """  文件复制功能

    :param sourcefile:  源文件
    :param destfile:    目标文件
    """
    dest_path, dest_file = os.path.split(destfile)
    if os.path.isfile(dest_file):
        print("目标文件已存在！")
        sys.exit(100)
    with open(sourcefile, "rb") as read_f, \
            open(dest_file, "wb") as write_f:
        for read in read_f:
            read_f.seek(0, 0)
            write_f.write(read_f.read())
        print("复制成功")

the_cp(r"C:/Users/xiong/Desktop/py练习/刷博客/03-模块/z04-sys实现cp功能.py", r"z04-sys实现cp功能1.py")
